﻿using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel;

namespace MvcShop.Models
{
    [MetadataType(typeof(ProductMetadata))]
    public partial class Product
    {
    }

    public class ProductMetadata
    {
        [DisplayName("商品ID")]
        public int ProductId { get; set; }

        [Required(ErrorMessage = "商品名称不能为空.")]
        [StringLength(250, ErrorMessage = "商品名称不能超过250个字节.")]
        [DisplayName("商品名称")]
        public string ProductName { get; set; }

        [Required(ErrorMessage="类别没有选择.")]
        [DisplayName("类别")]
        public int CategoryId { get; set; }

        [Required]
        [Range(1, 4, ErrorMessage = "显示位置不正确.")]
        [DisplayName("显示位置")]
        public int Position { get; set; }

        [Required(ErrorMessage = "关键字不能为空。")]
        [StringLength(250, ErrorMessage = "关键字不能超过250个字节.")]
        [DisplayName("")]
        public string KeyWord { get; set; }

        [Required(ErrorMessage = "商品简述不能为空。")]
        [StringLength(250, ErrorMessage = "商品简述不能超过250个字节.")]
        [DisplayName("商品简述")]
        public string SeoDescription { get; set; }

        [Required(ErrorMessage = "进货价格不能为空")]
        [DataType(DataType.Currency,ErrorMessage="请输入正确的金额。")]
        [DisplayName("进货价格")]
        public decimal BuyPrice { get; set; }

        [Required(ErrorMessage = "市场价格不能为空")]
        [DataType(DataType.Currency, ErrorMessage = "请输入正确的金额。")]
        [DisplayName("市场价格")]
        public decimal MarkePrice { get; set; }

        [Required(ErrorMessage = "优惠价格不能为空")]
        [DataType(DataType.Currency, ErrorMessage = "请输入正确的金额。")]
        [DisplayName("优惠价格")]
        public decimal SellPrice { get; set; }

        [Required(ErrorMessage = "详细信息不能为空")]
        [DataType(DataType.Text)]
        [DisplayName("详细信息")]
        public string Description { get; set; }

        [StringLength(50, ErrorMessage = "制造商不能超过50个字节")]
        [DisplayName("制造商")]
        public string Manufacturer { get; set; }

        [StringLength(50, ErrorMessage = "产地不能超过50个字节")]
        [DisplayName("商品产地")]
        public string Producer { get; set; }

        [DataType(DataType.Currency)]
        [DisplayName("商品重量")]
        public decimal Weight { get; set; }

        [Required(ErrorMessage = "库存不能为空。")]
        [DisplayName("商品库存")]
        public int Stock { get; set; }
    }
    public enum PositionType
    {
        普通商品 = 1,
        推荐商品 = 2,
        热门商品 = 3,
        特价商品 = 4,
        最新上架 = 5
    }
}
